﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;

namespace WindowsService
{
    public partial class Service1 : ServiceBase
    {
        private System.Timers.Timer timer1 = new System.Timers.Timer();
        public Service1()
        {
            InitializeComponent();
        }
        protected override void OnStart(string[] args)
        {
            timer1.Elapsed += new System.Timers.ElapsedEventHandler(timer1_Elapsed);
            timer1.Interval = 1000; // 1 sec
            timer1.Enabled = true;
        }
        void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            var task = new ServiceTask();
            task.TaskSwitcher(DateTime.Now);
        }
        protected override void OnStop()
        {
            timer1.Stop();
        }
    }
}
